<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script>
        var welcome = 'welcome'
        var ctx = '${ pageContext.request.contextPath}';
        $(function () {
            $(".nav-active").removeClass("nav-active")
            let type = '${ entityName}';
            $("#"+type+"Active").addClass("nav-active")
        })
    </script>
</head>

<header class="header">
    <div class="m-body">
        <!-- <img class="logo fl" src="${ pageContext.request.contextPath}/web/assets/img/logo.jpg"> -->
        <a class="title" href="${ pageContext.request.contextPath}/welcome"><h1 class="fl">${ sysName }</h1></a>
        <ul class="nav fl">
            <li id="carActive"><a href="${ pageContext.request.contextPath}/welcome?entityName=car">汽车</a></li>
            <li id="starActive"><a href="${ pageContext.request.contextPath}/welcome?action=stars">我的收藏</a></li>
        </ul>
        <div class="fr login-info">
        <c:if test="${ sessionScope.user==null}">
            <a href="${ pageContext.request.contextPath}/login.jsp">登录</a>　
            <span><a href="${ pageContext.request.contextPath}/register.jsp">注册</a></span>
        </c:if>
        <c:if test="${ sessionScope.user !=null}">
            <a href="${ pageContext.request.contextPath}/hello.jsp">您好，${ sessionScope.user.username}</a>　
            <a href="${ pageContext.request.contextPath}/logout">退出登陆</a>　
        </c:if>
        </div>
        <div class="search-div fr">
            <form action="${ pageContext.request.contextPath}/welcome" method="get">
                <input class="search-input" value="${ title }" type="text" id="title" name="title"/>
                <input value="${ entityName}" type="hidden" name="entityName"/>
                <input class="search-btn" type="submit" value="搜索">
            </form>
        </div>
    </div>
</header>

